# -*- coding:utf-8 -*-
import requests
import json
import configparser
import os

con = configparser.ConfigParser()
con.read("config.ini")
URL = con.get("address","url")
TYPE = con.get("types","type")
FILE = con.get("files","file")

def ner(content):
    list = []
    tage = 0
    for l in content:
        data = {'text':l.strip("\n").strip()}
        r1 = requests.post(URL,data = data)
        r = json.loads(r1.text)
        for j in r["result"][-1].values():
            if j == TYPE:
                tage = 0
                break
            else:
                tage = 1
        if tage == 1:
            list.append(l)
    return list

def readFile(path):
    result = []
    with open(path, 'r') as f:
        while 1:
            line = f.readline()
            if not line:
                break
            else:
                result.append(line)
    return result

if __name__ == "__main__":
    file = readFile(FILE)  #读文件
    list = ner(file)  #判断是否实体识别返回
    for i in list:
        print "%s is not ner" % json.dumps(i, ensure_ascii=False, encoding='UTF-8')







